﻿package situ.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import situ.entity.Emp;
import situ.service.EmpService;

import javax.servlet.http.HttpSession;
import java.util.*;
@Controller
public class EmpController {

@Autowired
    EmpService service;

@Value("${xx.name}")
String name;

    @GetMapping("/show")
    public String show(HttpSession session, Map map){

        session.setAttribute("user", "邹豪是个大傻吊");

        map.put("mess", "第一个springboot项目就做好了"+name);

        map.put("items", service.queyall2());

        return "index.html";
    }


    @ResponseBody
    @GetMapping("/showjson")
    public List<Emp> show2(){
        System.out.println("aaa");
        return  service.queyall() ;  //自动转json 不用写Gson gson=new Gosn() gson.toJson()
    }



    @GetMapping("show.html")
    public String index(){
        return "redirect:show"; //重定向
      //  return "show.html";
    }
}
